<template>
  <div>
    <!-- 折线图 -->
    <div class="line" ref="echar"></div>
  </div>
</template>

<script>
import * as echarts from "echarts";
export default {
  props: ["color"],
  mounted() {
    // 初始化echarts
    let myCharts = echarts.init(this.$refs.echar);
    // console.log(myCharts);
    myCharts.setOption({
      xAxis: { type: "category", show: false },
      yAxis: { show: false },
      // 设置配置项
      series: [
        {
          type: "line",
          data: [10, 60, 1, 62, 34, 55],
          //   设置平滑
          smooth: true,
          //   拐点样式设置
          itemStyle: {
            opacity: 0,
          },
          lineStyle: {
            color: this.color,
          },
          //   渐变
          areaStyle: {
            color: {
              type: "linear",
              x: 0,
              y: 0,
              x2: 0,
              y2: 1,
              colorStops: [
                {
                  offset: 0,
                  color: this.color,
                },
                {
                  offset: 1,
                  color: "#fff",
                },
              ],
              global: false,
            },
          },
        },
      ],
      //   设置成宽高全部
      grid: {
        top: 0,
        left: 0,
        right: 0,
        bottom: 0,
      },
    });
  },
};
</script>

<style lang="scss" scoped>
.line {
  width: 100%;
  height: 100%;
  height: 80px;
}
</style>
